package com.example.zpositionanimationdemo.slice;

import com.example.zpositionanimationdemo.ResourceTable;
import com.sxu.shadowdrawable.ShadowDrawable;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.DependentLayout;
import ohos.agp.utils.Color;
import ohos.agp.window.service.DisplayManager;
import ohos.agp.window.service.WindowManager;

public class ShadowStylesSlice extends AbilitySlice {
    private DependentLayout id_two,id_three,id_four,id_six,id_one,id_five;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_shadowstyles);
        initView();
        initDate();
    }

    private void initDate() {
        int dptopxs = 0;
        int dptopxd = 4;
        int offsety = 4;
        ShadowDrawable.setShadowDrawable(id_one, Color.getIntColor("#FFFFFF"), dpToPx(dptopxs),
                Color.getIntColor("#FFD7D7D7"), dpToPx(dptopxd), 0, offsety);
        ShadowDrawable.setShadowDrawable(id_three, Color.getIntColor("#FFFFFF"), dpToPx(dptopxs),
                Color.getIntColor("#FFD7D7D7"), dpToPx(dptopxd), 0, offsety);
        ShadowDrawable.setShadowDrawable(id_five, Color.getIntColor("#FFFFFF"), dpToPx(dptopxs),
                Color.getIntColor("#FFD7D7D7"), dpToPx(dptopxd), 0, offsety);
        int dptopxsa = 0;
        int dptopxda = 6;
        int offsetya = 6;
        ShadowDrawable.setShadowDrawable(id_two, Color.getIntColor("#FFFFFF"), dpToPx(dptopxsa),
                Color.getIntColor("#FFC1C1C1"), dpToPx(dptopxda), 0, offsetya);
        ShadowDrawable.setShadowDrawable(id_four, Color.getIntColor("#FFFFFF"), dpToPx(dptopxsa),
                Color.getIntColor("#FFC1C1C1"), dpToPx(dptopxda), 0, offsetya);
        ShadowDrawable.setShadowDrawable(id_six, Color.getIntColor("#FFFFFF"), dpToPx(dptopxsa),
                Color.getIntColor("#FFC1C1C1"), dpToPx(dptopxda), 0, offsetya);
    }

    private void initView() {
        id_one = (DependentLayout) findComponentById(ResourceTable.Id_one);
        id_two = (DependentLayout) findComponentById(ResourceTable.Id_two);
        id_three = (DependentLayout) findComponentById(ResourceTable.Id_three);
        id_four = (DependentLayout) findComponentById(ResourceTable.Id_four);
        id_five = (DependentLayout) findComponentById(ResourceTable.Id_five);
        id_six = (DependentLayout) findComponentById(ResourceTable.Id_six);
        WindowManager.getInstance().getTopWindow().get().setStatusBarColor(-13615201);
    }

    private int dpToPx(int dp) {
        double density = DisplayManager.getInstance().getDefaultDisplay(this).get().getAttributes().densityPixels;
        return (int) ( dp * density + 0.5f);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
